package interfazUsuario;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import cultivameCore.color.ColorRGB;

public class ColoresIU extends JPanel {
	private static final long serialVersionUID = 1L;
	JLabel lbl_color=new JLabel();
	JScrollBar sc=new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, -100, 1000);
	JLabel lbl_scvalue=new JLabel(sc.getValue()+"");
	
	public ColoresIU(){
		this.setMinimumSize(new Dimension(250,250));
		setBorder(BorderFactory.createTitledBorder("ColorBox&Scroll"));
		
		sc.addAdjustmentListener(new AdjustmentListener(){

			@Override
			public void adjustmentValueChanged(AdjustmentEvent e) {
				// TODO Auto-generated method stub
				ColorRGB c=ColorRGB.lonOndaToRGB(e.getValue());
				lbl_color.setBackground(new Color(c.getRed(), c.getGreen(), c.getBlue()));
				lbl_scvalue.setText(e.getValue()+"");
			}
			
		});
		this.setLayout(new GridBagLayout());
		GridBagConstraints c=new GridBagConstraints();
		
		c.gridx=0;
		c.gridy=0;
		c.gridwidth=1;
		c.gridheight=1;
		c.weightx=1;
		c.weighty=1;
		c.anchor=GridBagConstraints.CENTER;
		c.fill=GridBagConstraints.BOTH;
		c.insets=new Insets(0,0,0,0);
		lbl_color.setOpaque(true);
		this.add(lbl_color, c);
		
		c.gridx=0;
		c.gridy=1;
		c.gridwidth=1;
		c.gridheight=1;
		c.weightx=1;
		c.weighty=1;
		c.anchor=GridBagConstraints.CENTER;
		c.fill=GridBagConstraints.HORIZONTAL;
		c.insets=new Insets(0,0,0,0);
		this.add(sc, c);
		
		c.gridx=0;
		c.gridy=2;
		c.gridwidth=1;
		c.gridheight=1;
		c.weightx=1;
		c.weighty=1;
		c.anchor=GridBagConstraints.CENTER;
		c.fill=GridBagConstraints.NONE;
		c.insets=new Insets(0,0,0,0);
		this.add(lbl_scvalue, c);
		setVisible(true);
	}
}
